package com.gitee.wsl.collections.map

import com.gitee.wsl.collections.map.multi.MultiKeyMap
import com.gitee.wsl.ext.coroutines.set
import kotlinx.atomicfu.AtomicRef
import kotlinx.atomicfu.atomic
import kotlin.concurrent.atomics.ExperimentalAtomicApi
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNull


class MultiKeyMapTest {

    @OptIn(ExperimentalAtomicApi::class)
    @Test
    fun testMultiKeyMapTest(){
        val k1 = atomic("K1v1")
        val k2 = atomic("K2v1")
        val map = MultiKeyMap<AtomicRef<String>, String>()
        assertNull(map.put(k1, k2, "V"))
        assertEquals("V", map.get(k1, k2))
        k1.set("K1v2")
        assertEquals("V", map.get(k1, k2))
        assertEquals("V", map.get(k1, k2))
    }
}